home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Mail For Me / Mail4ME.jar / de / trantor / mail / j2me / ConnectionImpl.class (.txt)
Encoding:
Java Class File  |  2001-10-21  |  1.6 KB  |  33 lines

  1. package de.trantor.mail.j2me;
  2.  
  3. import de.trantor.mail.Connection;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.io.OutputStream;
  7. import javax.microedition.io.Connector;
  8. import javax.microedition.io.StreamConnection;
  9.  
  10. public class ConnectionImpl extends Connection {
  11.    private StreamConnection socket;
  12.  
  13.    public void open(String host, int port) throws IOException {
  14.       this.socket = (StreamConnection)Connector.open("socket://" + host + ":" + port);
  15.    }
  16.  
  17.    public void close() throws IOException {
  18.       if (this.socket != null) {
  19.          this.socket.close();
  20.          this.socket = null;
  21.       }
  22.  
  23.    }
  24.  
  25.    public InputStream getInputStream() throws IOException {
  26.       return this.socket != null ? this.socket.openInputStream() : null;
  27.    }
  28.  
  29.    public OutputStream getOutputStream() throws IOException {
  30.       return this.socket != null ? this.socket.openOutputStream() : null;
  31.    }
  32. }
  33.